package cn.iocoder.yudao.module.shop.dal.mysql.daystatistics;

import java.time.LocalDateTime;
import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.shop.dal.dataobject.daystatistics.ShopDayStatisticsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.shop.controller.admin.daystatistics.vo.*;

/**
 * 每日手工费统计 Mapper
 *
 * @author 曹建伟
 */
@Mapper
public interface ShopDayStatisticsMapper extends BaseMapperX<ShopDayStatisticsDO> {

    default PageResult<ShopDayStatisticsDO> selectPage(ShopDayStatisticsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ShopDayStatisticsDO>()
                .eqIfPresent(ShopDayStatisticsDO::getDateId, reqVO.getDateId())
                .betweenIfPresent(ShopDayStatisticsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShopDayStatisticsDO::getId));
    }

    default List<ShopDayStatisticsDO> selectList(ShopDayStatisticsExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ShopDayStatisticsDO>()
                .eqIfPresent(ShopDayStatisticsDO::getDateId, reqVO.getDateId())
                .betweenIfPresent(ShopDayStatisticsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShopDayStatisticsDO::getId));
    }

    default List<ShopDayStatisticsDO> selectList(LocalDateTime startTime, LocalDateTime endTime, Long tenantId){
        return selectList(new LambdaQueryWrapperX<ShopDayStatisticsDO>()
                .eq(ShopDayStatisticsDO::getTenantId, tenantId)
                .between(ShopDayStatisticsDO::getCreateTime, startTime, endTime));
    }

    default ShopDayStatisticsDO selectByDateId(String dateId, Long tenantId){
        return selectOne(new LambdaQueryWrapperX<ShopDayStatisticsDO>()
                .eq(ShopDayStatisticsDO::getDateId, dateId)
                .eq(ShopDayStatisticsDO::getTenantId, tenantId));
    }

}
